<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      @keyframes ColorChange {
        0% {
          outline: 1px solid lightgreen;
        }

        50% {
          outline: 1px solid green;
        }

        100% {
          outline: 1px solid lightgreen;
        }
      }

      svg {
        outline: 1px solid red;
        animation: ColorChange 500ms ease infinite;
      }

      line,
      polyline,
      rect {
        stroke-linecap: round;
        stroke-linejoin: round;
      }
    </style>
  </head>

  <body>
    <svg width="500"
         height="500"
         xmlns="http://www.w3.org/2000/svg"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         preserveAspectRatio="xMinYMin meet"
         viewBox="0 0 500 500">
      <g id="square"
         transform="translate(0,500) scale(1,-1)">
        <rect x="0"
              y="0"
              width="20"
              height="20"
              style="fill: black; stroke-width: 2;" />
        <rect x="50"
              y="50"
              width="20"
              height="20"
              style="fill: green; stroke-width: 2;" />
        <rect x="100"
              y="100"
              width="20"
              height="20"
              fill="red"
              fill-opacity="0.2"
              stroke-width="2"
              transform="scale(1)" />
        <rect x="100"
              y="100"
              width="20"
              height="20"
              fill="green"
              fill-opacity="0.2"
              stroke-width="2"
              transform="translate(-110,-110) scale(2)" />
        <rect x="100"
              y="100"
              width="20"
              height="20"
              fill="blue"
              fill-opacity="0.2"
              stroke-width="2"
              transform="translate(-165,-165) scale(2.5)" />
      </g>

      <!-- 围绕中心点缩放 -->
      <!-- 公式：transform: translate(-centerX*(factor-1),-centerY*(factor-1)) scale(factor); -->

    </svg>
  </body>

</html>
